package net.wexoo;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import at.heurigen.app.R;

public class SQLiteExporter extends Activity {

	public static Context mainContext;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		mainContext = this;
	}

	public static void showShortToast(String text) {
		Toast.makeText(mainContext, text, Toast.LENGTH_LONG).show();
	}

	/**
	 * Check for sd card,... availability
	 * 
	 * @return wether sd card ot other external storage is available
	 */
	public boolean isExternalStorageAvailable() {
		return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
	}

	private void exportToSd(View view) {
		String dbPackage = ((EditText) findViewById(R.id.et_package)).getText().toString();
		String dbName = ((EditText) findViewById(R.id.et_database)).getText().toString();
		
		if(!dbPackage.equals("") && !dbName.equals("")){
			if (isExternalStorageAvailable()) {
				new ExportDatabaseFileTask(mainContext,).execute();
			} else {
				showShortToast("External storage is not available, unable to export data.");
			}
		} else {
			
		}
	}
}